﻿

using BaseData.DomainLib.AggregatesModel.SaleOrderAggregate;
using Microsoft.EntityFrameworkCore;
using Swimj.DomainLib.SeedWork;

namespace BaseData.InfrastructureLib.Repositories;

public class SaleOrderRepository: ISaleOrderRepository
{
    private readonly BaseDataDbContext _baseDataDbContext;

    public IUnitOfWork UnitOfWork => _baseDataDbContext;

    public SaleOrderRepository(BaseDataDbContext baseDataDbContext)
    {
        this._baseDataDbContext = baseDataDbContext;
    }

    public SaleOrder Add(SaleOrder supplier)
    {
        return _baseDataDbContext.SaleOrders.Add(supplier).Entity;
    }

    public async Task<SaleOrder?> Get(int id)
    {
        return await _baseDataDbContext.SaleOrders.FirstOrDefaultAsync(supplier => supplier.Id == id);
    }
}